new Vue({
    el: "#mainContent",
    data: {
        userName: "",
        userPwd: "",
        loginUrl: "/admin/login.ajax",
        indexUrl: "/admin/index"
    },
    methods: {
        submit: function () {
            console.log("submit");
            this.$http.post(this.loginUrl, {
                name: this.userName,
                pwd: this.userPwd
            }, {emulateJSON: true})
                .then((response) => {
                    console.log(JSON.stringify(response.data));
                    if (Number(response.data.code) == 0) {  //登录成功
                        window.location.href = this.indexUrl + "?userName=" + response.data.data.userName;
                    } else {
                        alert("用户名或密码错误!");
                    }
                })
                .catch(function (response) {
                    console.log(response)
                });
        }
    }
});